package ac.svn.accesscontrol.ui.helper.formatter;

import ac.svn.accesscontrol.store.SVNLocation;
import ac.svn.accesscontrol.ui.IListItemTextFormatter;

public class LocationItemNameFormatter implements IListItemTextFormatter
{

    @Override
    public String formatString(Object msgObj) 
    {
	String formattedText = "";
	SVNLocation location = (SVNLocation) msgObj;
	if(location.getLocationName().equalsIgnoreCase(location.getLocationPath()))
	{
	    formattedText = String.format("<HTML>Rights: [<b>%02d</b>] Location: [<b>%s</b>] </HTML>", location.getAccessUnits().size(),location.getLocationName());
	}
	else
	{
	    formattedText = String.format("<HTML>Rights: [<b>%02d</b>] %s [<b>%s</b>] </HTML>", location.getAccessUnits().size(),location.getLocationName(),location.getLocationPath());
	}
	return formattedText;
    }

    @Override
    public String formatToolTip(Object msgObject) 
    {
	return formatString(msgObject);
    }

}